using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using JGSY.CMS.LowCode.Platform.Domain.Entities;

namespace JGSY.CMS.LowCode.Platform.Domain.Interfaces
{
    /// <summary>
    /// 部门仓储接口
    /// </summary>
    public interface IDepartmentRepository : IRepository<Department>
    {
        /// <summary>
        /// 根据编码查找部门
        /// </summary>
        /// <param name="code">部门编码</param>
        /// <returns>部门实体</returns>
        Task<Department?> GetByCodeAsync(string code);

        /// <summary>
        /// 获取子部门列表
        /// </summary>
        /// <param name="parentId">父部门ID</param>
        /// <returns>子部门列表</returns>
        Task<List<Department>> GetChildrenAsync(long parentId);

        /// <summary>
        /// 获取顶级部门列表
        /// </summary>
        /// <returns>顶级部门列表</returns>
        Task<List<Department>> GetRootDepartmentsAsync();

        /// <summary>
        /// 检查部门编码是否存在
        /// </summary>
        /// <param name="code">部门编码</param>
        /// <param name="excludeId">排除的ID</param>
        /// <returns>是否存在</returns>
        Task<bool> IsCodeExistsAsync(string code, long? excludeId = null);

        /// <summary>
        /// 获取部门路径
        /// </summary>
        /// <param name="departmentId">部门ID</param>
        /// <returns>从根到该部门的路径</returns>
        Task<List<Department>> GetPathAsync(long departmentId);

        /// <summary>
        /// 获取活跃部门列表
        /// </summary>
        /// <returns>活跃部门列表</returns>
        Task<List<Department>> GetActiveDepartmentsAsync();
        Task<IEnumerable<Department>> GetQueryableAsync();
    }
}
